<script setup>
import { ref } from 'vue'
import BankLogin from './components/BankLogin.vue'
import AdminDashboard from './components/AdminDashboard.vue'
import UserDashboard from './components/UserDashboard.vue'

const currentPage = ref('login') // 'login'、'admin' 或 'user'

const handleAdminLoginSuccess = (back) => {
  console.log(back)
  adminID = back
  currentPage.value = 'admin'
}

const handleUserLoginSuccess = (back) => {
  console.log(back)
  customerID = back
  currentPage.value = 'user'
}

const handleLogout = () => {
  currentPage.value = 'login'
}

let adminID = 0
let customerID = 0
</script>

<template>
  <BankLogin 
    v-if="currentPage === 'login'" 
    @admin-login-success="handleAdminLoginSuccess"
    @user-login-success="handleUserLoginSuccess"
  />
  <AdminDashboard v-else-if="currentPage === 'admin'" @logout="handleLogout" :adminData="adminID" />
  <UserDashboard v-else-if="currentPage === 'user'" @logout="handleLogout" :userID="customerID" />
</template>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
</style>
